import { http } from "../../utils/http";
Page({
    data: {
        list: [],       //医院列表
        page: 1,
        loading:true
    },
    //页面加载，生成列表页
    onLoad() {
        //获取第1页内容
        this.getPage()

    },
    async getPage() {
        let result = await http({
            url: "1700-2",
            data: {
                classifyId: 1,
                page: this.data.page            //2
            }
        }).catch(err => console.error(err))

        let newData = result.data.showapi_res_body.contentlist
        this.setData({
            //新一页的数据，需要和原来数据拼接，然后渲染到页面
            list: this.data.list.concat(newData),
            loading:false

        })
    },
    //触底加载更多
    onReachBottom(){
        this.data.page++            //2
        this.getPage()
    },
    //跳转详情页，携带id
    toDetail(e){
        let id=e.currentTarget.id;      //获取童话故事id
        wx.navigateTo({
          url: '/pages/detail/detail?id='+id,
        })
    }


})